package iso8583

//需要填充的字符
var (
	ZERO  = byte('0') //数字字符填充0
	BLANK = byte(' ') //数字和字符组合或者是字符填充空白符
)

//LeftPading 左靠 导致右边空余 使用特定字符填充
func LeftPading(b []byte, length int, pading byte) []byte {
	pad := length - len(b)
	if pad <= 0 {
		return b
	}
	lb := make([]byte, length)
	for i := len(b); i < length; i++ {
		lb[i] = pading
	}
	//lb = append(b[0:], lb[len(b):]...)
	for i := 0; i < len(b); i++ {
		lb[i] = b[i]
	}
	return lb
}

//RightLading 右靠左填充
func RightLading(b []byte, length int, pading byte) []byte {
	pad := length - len(b)
	if pad <= 0 {
		return b
	}
	lb := make([]byte, length)
	for i := 0; i < pad; i++ {
		lb[i] = pading
	}
	//lb = append(b[0:], lb[len(b):]...)
	for i := pad; i < length; i++ {
		lb[i] = b[i-pad]
	}
	return lb
}
